Skip to content

feat(series): #1098 arithmetic addition #1275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

cmp0xff
Copy link
Contributor

@cmp0xff cmp0xff commented Jul 13, 2025

This PR is motivated by #1273 (review).

Comprehensive plan (maybe in another PR)

Inspired by #1093, one can draft the following comprehensive plan for all possible combinations of the left arithmetic operand, the binary arithmetic operator and the right arithmetic operand.

Left operand

  • Series[Any]
  • Series[int]
  • Series[float]
  • Series[complex]

Binary arithmetic operators

Include their right-version and functional version. In add we give a full example. We follow the official documentation.

  • __add__, __radd__, add, radd
  • __truediv__
  • __floordiv__
  • __pow__
  • __mod__
  • __mul__
  • __sub__

Right operand

  • Scalar
  • Sequence
  • numpy arrays
  • Series

Draft of a plan

  • We can have 4 ~ 5 test scripts for each left operand
  • In each test script, we can have 7 test functions for each binary arithmetic operator
  • In each test function, we test on all right operands. Do not forget the possible four variations, see the example of add.

Checklist

@cmp0xff cmp0xff marked this pull request as ready for review July 13, 2025 16:32
Copy link
Member

@loicdiridollou loicdiridollou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like great progress here!

@cmp0xff cmp0xff marked this pull request as draft July 14, 2025 16:51
@cmp0xff cmp0xff force-pushed the feature/cmp0xff/1098-__add__-and-__mul__ branch from 3b3f899 to bf79de1 Compare July 15, 2025 09:29
@cmp0xff cmp0xff force-pushed the feature/cmp0xff/1098-__add__-and-__mul__ branch 2 times, most recently from 02c646d to 8f43efc Compare July 15, 2025 15:25
@cmp0xff cmp0xff changed the title feat(series): #1098 __add__ and __mul__ feat(series): #1098 additions Jul 15, 2025
@cmp0xff cmp0xff changed the title feat(series): #1098 additions feat(series): #1098 arithmetic additions Jul 15, 2025
@cmp0xff cmp0xff changed the title feat(series): #1098 arithmetic additions feat(series): #1098 arithmetic addition Jul 15, 2025
@cmp0xff cmp0xff marked this pull request as ready for review July 15, 2025 16:57
cmp0xff added a commit to cmp0xff/pandas-stubs that referenced this pull request Jul 16, 2025
Copy link
Member

@twoertwein twoertwein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @cmp0xff!

I approved but I will let @Dr-Irv review/merge when he is back as this is a larger MR. I think adding all these overloads is in the the spirit of what pandas-stubs has been doing (but it might also create more maintenance burden).

(Personally, I'm still hoping for something like this #820 (comment) which would be more generic, but not supported by today's type checkers/python type system)

cmp0xff added a commit to cmp0xff/pandas-stubs that referenced this pull request Jul 17, 2025
@cmp0xff cmp0xff force-pushed the feature/cmp0xff/1098-__add__-and-__mul__ branch from e101ff4 to 14f79a0 Compare July 17, 2025 07:32
@cmp0xff cmp0xff force-pushed the feature/cmp0xff/1098-__add__-and-__mul__ branch from 14f79a0 to 2b94ab0 Compare July 17, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Addition of a Series[int] with a complex returns Series[unknown]
3 participants